using LitJson;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;
using static UnityEngine.UI.CanvasScaler;

namespace AFAD
{
    public class WebReqSkipCert : CertificateHandler
    {
        protected override bool ValidateCertificate(byte[] certificateData)
        {
            return true;
        }
    }

    public enum Analysis { 
        AD,
        APPFLYER,
    }


    public class GameSceneMgr : MonoBehaviour
    {
        public static GameSceneMgr Instance = null;
        [SerializeField] private GameObject Webview;
        [SerializeField] private GameObject Game;
        [SerializeField] private GameObject Loading;
        [SerializeField] private string UrlLocal;
        [SerializeField] public Analysis AnalysisTy;
        [HideInInspector] public Dictionary<string, string> AdEventTokens = new Dictionary<string, string>();
        [HideInInspector] public Dictionary<string, AdjustData> AdjustDatas = new Dictionary<string, AdjustData>();

        private void Awake()
        {
            Instance = this;
            Webview.SetActive(false);
            Game.SetActive(false);
            Loading.SetActive(false);
        }

        private void Start()
        {
            var url = UniWebViewHelper.StreamingAssetURLForPath("local_www/index.html");
            Webview.GetComponent<UniWebView>().SetUrl(url);
            Webview.SetActive(true);
        }

        public void SetLoading(bool active) {
            Loading.SetActive(active);
        }

        public void InterstitialBack(bool adBack)
        {
            Webview.GetComponent<WebHandles>().InterstitialBack(adBack);
        }

        public void RewardedBack(bool adBack, string ty)
        {
            Webview.GetComponent<WebHandles>().RewardedBack(adBack, ty);
        }
    }
}
